<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/27
 * Time: 10:56
 */

namespace app\mobile\controller;


use cmf\controller\HomeBaseController;
use think\Db;

class ApiController extends HomeBaseController
{
    /**
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 个人主页接口
     */
    public function personal_page()
    {
        //获取律师id
        $id = request()->param('id');
        $case_info = Db::name('portal_post')->where('team_id',"<>",0)->where('team_id',$id)->find();

        return json($case_info);
    }


    /**
     * @return \think\response\Json
     * @throws \think\exception\DbException
     * number  每页条数
     * 案例
     */
    public function case_list()
    {
        //每页条数
        $number = request()->param('number');
        $case_list = Db::name('portal_post')->where('team_id',"<>",0)->where('delete_time',0)->order('post_hits desc')->paginate($number);

        return json($case_list);
    }

    /**
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 案例详情
     */
    public function case_details()
    {
        $id = request()->param('id');

        $details = Db::name('portal_post' )->alias('p')->join('team t','p.team_id = t.id')->where('p.id',$id)->select();

        return json($details);
    }


}